package com.ihr360.job.core;

import com.ihr360.job.core.entity.StepExecution;

public interface StepExecutionListener extends StepListener {

    /**
     * Initialize the state of the listener with the {@link StepExecution} from
     * the current scope.
     *
     * @param stepExecution
     */
    void beforeStep(StepExecution stepExecution);

    /**
     * Give a listener a chance to modify the exit status from a step. The value
     * returned will be combined with the normal exit status using
     * {@link ExitStatus#and(ExitStatus)}.
     *
     * Called after execution of step's processing logic (both successful or
     * failed). Throwing exception in this method has no effect, it will only be
     * logged.
     *
     * @return an {@link ExitStatus} to combine with the normal value. Return
     * null to leave the old value unchanged.
     */
    ExitStatus afterStep(StepExecution stepExecution);
}
